import got from 'got'
import { PhoneResponse, HolidayInfo } from '../interface/phone.interface.ts'

class PhoneCardService {
  // 获取手机卡流量信息
  async getCardData(card: string) {
    const Params = {
      card,
    }
    const { data }: PhoneResponse = await got
      .post('http://39.108.102.213:8898/iot/card/queryCardInfo', {
        json: Params,
      })
      .json()
    return data
  }

  // 获取指定日期的节假日信息 - 提莫的神秘小站提供的 API
  async getTimorHolidayInfo(date: string): Promise<HolidayInfo> {
    return await got(`http://timor.tech/api/holiday/info/${date}`).json()
  }
}

const phoneCardService = new PhoneCardService()
export const { getCardData, getTimorHolidayInfo } = phoneCardService
export default phoneCardService
